
package com.mp.chart.markerview;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.mp.chart.components.MarkerView;
import com.mp.chart.data.Entry;
import com.mp.chart.data.KLineData;
import com.mp.chart.data.MinutesData;
import com.android.R;

public class XAxisMarkerView extends MarkerView {


    private TextView tvContent;
    private String typeIndex;

    public XAxisMarkerView(Context context, int layoutResource, String typeIndex) {
        super(context, layoutResource);
        this.typeIndex = typeIndex;
        tvContent = (TextView) findViewById(R.id.tvContent);
        View body = findViewById(R.id.llBody);
        body.setBackgroundColor(getResources().getColor(R.color.main_footer_bg));
    }

    @Override
    public void refreshContent(Entry e, int dataSetIndex) {

//        MinutesData data = (MinutesData) e.getData();
//
//
        Object data = e.getData();
        String date="";
        String strForm="MM-dd HH:mm";

        switch (typeIndex) {
            case "min":
            case "1m":
                String time0 =((KLineData) data).date;
                date = time0;
                break;
            case "1h":
            case "day":
            case "month":
            case "kline":
                String time = ((KLineData) data).date;
                date = time;
                break;
            case "5":
            case "30":
            case "60":
                String time2 = ((KLineData) data).date;
                date = time2;
                break;

        }


        tvContent.setText(date);
    }

    @Override
    public int getXOffset() {
//        return 0;
        return -getWidth() / 2;
    }

    @Override
    public int getYOffset() {
//        return 0;
        return 0;
    }
}
